﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UPMS.Core.Domain.Mapping
{
    public class GroupMap : BaseMap<Group>
    {
        public GroupMap()
        {
            this.ToTable("Upms_tbl_Group");
            this.Property(a => a.ApplicationId).HasColumnName("ApplicationId");
            this.Property(a => a.Name).HasColumnName("Name").HasMaxLength(64).IsRequired();

            this.HasRequired(g => g.Application).WithMany(a => a.Groups).HasForeignKey(g => g.ApplicationId);
            this.HasMany(g => g.Roles).WithOptional(r => r.Group).HasForeignKey(r => r.GroupId);
        }
    }
}
